-
-
Notifications
You must be signed in to change notification settings - Fork 635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revert most of #438 and improve const-correctness #578
Conversation
a0d160f
to
ba947cb
Compare
At least the function parameters keep them as is, they are passed by value, not by const reference or const pointer; therefore the compiler will optimize them out. |
It is not about what the compiler produces. In fact, the generated binary is identical to the one without Take this bit from btop_tools.cpp: bool refresh(bool only_check) {
struct winsize w;
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) < 0) return false;
if (width != w.ws_col or height != w.ws_row) {
if (not only_check) {
width = w.ws_col;
height = w.ws_row;
}
return true;
}
return false;
}
If you want to know what If you see If a variable is not intended to be modified it should be declared It's not ideal that C++ is requiring you to explicitly make variables |
As I have suspected...well, I'm off; good luck. |
What's the issue? |
93e4df0
to
24fc998
Compare
Revert the removal of const qualifiers on bool paramteres and slap const on all variables that allow it to avoid accidental mutations and improve code readability
24fc998
to
7554b1d
Compare
@nobounce But I'm gonna hold off a bit on merging this since it touches code in a lot of places and will cause a lot of messy merges to code still in work in PR's and some branches. Have some big improvements planned from a related project I worked on recently. |
Sounds reasonable, most of this work was done with clang-tidy anyways, so easy to redo (or rebase) |
Reverts the removal of
const
-qualifiers on bools.Even if this produces the same binary it is good practice to be const-correct and not let developers accidentally change variables that shouldn't be modified